package cn.openea.perpartner.expert.web.controller;


import cn.openea.perpartner.common.core.utils.IdUtil;
import cn.openea.perpartner.common.core.web.controller.BaseController;
import cn.openea.perpartner.common.core.web.domain.AjaxResult;
import cn.openea.perpartner.expert.web.domain.dto.SelectDto;
import cn.openea.perpartner.expert.web.domain.dto.SignupDto;
import cn.openea.perpartner.expert.web.domain.entity.ExpertJob;
import cn.openea.perpartner.expert.web.service.IExpertJobService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 专家协作需求表(Job)表控制层
 *
 * @author Weird077
 * @since 2023-06-19 11:45:59
 */
@RestController
@RequestMapping("expert/job")
public class ExpertJobController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private IExpertJobService jobService;


    @GetMapping("/generate/taskNo")
    private AjaxResult autoDocNumber() {
        return AjaxResult.success("操作成功", IdUtil.autoDocNumber("XQ"));
    }

    @GetMapping("/{taskNum}")
    private AjaxResult selectJobInfo(@PathVariable String taskNum) {
        return success(jobService.getByTaskNum(taskNum));
    }

    @ApiOperation(value = "发布工作")
    @PostMapping("/publish/user")
    private AjaxResult publishJob(@RequestBody ExpertJob job) {

        return jobService.publishJob(job) ? success() : error();
    }

    @ApiOperation(value = "拍档抢单")
    @PostMapping("/grab")
    private AjaxResult grabJob(@RequestBody ExpertJob job) {
        return jobService.grabJob(job);
    }

    @ApiOperation(value = "拍档报名")
    @PostMapping("/signup/partner")
    private AjaxResult partnerSignup(@RequestBody SignupDto dto) {

        return jobService.partnerSignup(dto) ? success() : error();
    }

    @ApiOperation(value = "用户初选")
    @PostMapping("/preselect/user")
    private AjaxResult userPreselect(@RequestBody SelectDto dto) {

        return jobService.userPreselect(dto) ? success() : error();
    }

    @ApiOperation(value = "拍档参与复选")
    @PostMapping("/reselect/partner")
    private AjaxResult partnerReselect(@RequestBody SignupDto dto) {

        return jobService.partnerReselect(dto) ? success() : error();
    }

    @ApiOperation(value = "用户复选")
    @PostMapping("/reselect/user")
    private AjaxResult userReselect(@RequestBody SelectDto dto) {

        return jobService.userReselect(dto) ? success() : error();
    }

    @ApiOperation(value = "拍档确认参与")
    @PostMapping("/confirm/partner")
    private AjaxResult partnerConfirm(@RequestBody SignupDto dto) {

        return jobService.partnerConfirm(dto) ? success() : error();
    }


    @ApiOperation(value = "用户评价")
    @PostMapping("/evaluate")
    private AjaxResult userEvaluate(@RequestBody ExpertJob job) {

        return jobService.userEvaluate(job) ? success() : error();
    }


}

